﻿using System.Windows.Forms;
using BasecampRestAPI;

namespace BasecampUI
{
	public partial class CredentialsForm : Form, ICredentialsForm
	{
		readonly CredentialsFormMediator _mediator;
		public CredentialsForm()
		{
			InitializeComponent();
			_mediator = CredentialsFormMediator.GetInstance(this);
		}

		#region Implementation of ICredentialsForm

		public string UrlText
		{
			get { return urlTextBox.Text; }
			set { urlTextBox.Text = value; }
		}

		public string UserNameText
		{
			get { return userNameTextBox.Text; }
		}
		public string PasswordText
		{
			get { return passwordTextBox.Text; }
		}
		public void UserNameFocus()
		{
			ActiveControl = userNameTextBox;
		}
		public IRestWebService Service
		{
			get
			{
				return RestWebService.GetInstance(UrlText, UserNameText, PasswordText);
			}
		}

		#endregion

		private void CredentialsForm_Load(object sender, System.EventArgs e)
		{
			_mediator.Load();
		}
	}
}